/**
 *
 */
package vn.tecviets.thuandt.model.common;

import java.sql.Date;
import java.text.Normalizer;
import java.util.regex.Pattern;

/*
 * Common
 * 1.0
 * Mar 21, 2013
 * 
 * Copyright notice
 * 
 * Modification Logs:
 * 
 * DATE					AUTHOR				DESCRIPTION
 * -----------------------------------------------------------
 * Mar 21, 2013			Thuandt				Create
 */

public class Common {
	/**
	 * Get current datetime
	 * @return
	 */
	public static Date getCurrentDateTime() {
		java.util.Date utilDate = new java.util.Date();
		java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
		return sqlDate;
	}
	
	/**
	 * Converting Symbols, Accent Letters to English Alphabet
	 * Ex: Việt Nam --> Viet Nam
	 * @param str
	 * @return
	 */
	public String deAccent(String str) {
	    String nfdNormalizedString = Normalizer.normalize(str, Normalizer.Form.NFD); 
	    Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
	    return pattern.matcher(nfdNormalizedString).replaceAll("");
	}
}
